package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

//查询userinfo 表中一共有多少数据
public class JDBCDemo10 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()){
            Statement statement = connection.createStatement();
            String sql = "SELECT COUNT(*) count FROM userinfo";
            ResultSet rs = statement.executeQuery(sql);
            if (rs.next()){
                System.out.println("一共" + rs.getString("count") +"条记录");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
